﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            Load_HomeSlide();
            GetTopNews();
            Get5Res();
            GetTopResOnHome();
            GetKioskOnHome();
            GetCafeOnHome();
    }
    protected void Load_HomeSlide()
    {

        SQLHelper Dal = new SQLHelper();
        Dal.CommandType = CommandType.StoredProcedure;
        Dal.CommandText = "SP_GetHomeSlide";
        DataTable db = Dal.GetDataTable();
        rptSlideImage.DataSource = db;
        rptSlideImage.DataBind();
        rptSlideDes.DataSource = db;
        rptSlideDes.DataBind();

    }
    protected void GetTopNews()
    {
        SQLHelper Dal = new SQLHelper();
        Dal.CommandType = CommandType.StoredProcedure;
        Dal.CommandText = "SP_GetTop5NewestNews";
        DataTable db = Dal.GetDataTable();
        rptTopHotNews.DataSource = db;
        rptTopHotNews.DataBind();
    }
    protected void GetTopResOnHome()
    {
        try
        {
            SQLHelper Dal = new SQLHelper();
            Dal.CommandType = CommandType.StoredProcedure;
            Dal.CommandText = "SP_GetTopNhaHangOnHome";
            DataTable db = Dal.GetDataTable();
            rptRes.DataSource = db;
            rptRes.DataBind();
        }
        catch (Exception e)
        {
            Response.Write(e.Message);
        }
    }
    protected void GetKioskOnHome()
    {
        SQLHelper Dal = new SQLHelper();
        Dal.CommandType = CommandType.StoredProcedure;
        Dal.CommandText = "SP_GetTopKioskOnHome";
        DataTable db = Dal.GetDataTable();
        rptQuanNgon.DataSource = db;
        rptQuanNgon.DataBind();
    }
    protected void GetCafeOnHome()
    {
        SQLHelper Dal = new SQLHelper();
        Dal.CommandType = CommandType.StoredProcedure;
        Dal.CommandText = "SP_GetTopCafekOnHome";
        DataTable db = Dal.GetDataTable();
        rptCafe.DataSource = db;
        rptCafe.DataBind();
    }
    protected void Get5Res()
    {
        SQLHelper Dal = new SQLHelper();
        Dal.Open();
        Dal.CommandType = CommandType.StoredProcedure;
        Dal.CommandText = "SP_GetTop5ResHot";
        DataTable db = Dal.GetDataTable();
        Repeater2.DataSource = db;
        Repeater2.DataBind();
    }
}
